home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / performPathAnimation.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  24.5 KB  |  911 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  15 April 1997
  22. //  Author:         asg + clm
  23. //
  24. //  Description:
  25. //      Option box dialog for 'pathAnimation' command
  26. //
  27.  
  28.  
  29. //
  30. //  Procedure Name:
  31. //      setOptionVars
  32. //
  33. //  Description:
  34. //        Initialize the option values.
  35. //
  36. //  Input Arguments:
  37. //        Whether to set the options to default values.
  38. //
  39. //  Return Value:
  40. //      None.
  41. //
  42. proc setOptionVars(int $forceFactorySettings)
  43. {
  44.     //    FractionMode.
  45.     //
  46.     if ($forceFactorySettings || !`optionVar -exists pathAnimParametricLengthCB`) {
  47.         optionVar -intValue pathAnimParametricLengthCB 0;
  48.     }
  49.  
  50.     //    Follow.
  51.     //
  52.     if ($forceFactorySettings || !`optionVar -exists pathAnimFollowCB`) {
  53.         optionVar -intValue pathAnimFollowCB 1;
  54.     }
  55.  
  56.     if ($forceFactorySettings || !`optionVar -exists pathAnimFrontAxisRB`) {
  57.         optionVar -intValue pathAnimFrontAxisRB 1;
  58.         optionVar -intValue pathAnimPrevFrontAxis 1;
  59.     }
  60.  
  61.     if ($forceFactorySettings || !`optionVar -exists pathAnimUpAxisRB`) {
  62.         optionVar -intValue pathAnimUpAxisRB 2;
  63.         optionVar -intValue pathAnimPrevUpAxis 2;
  64.     }
  65.  
  66.     // World up
  67.  
  68.     if ($forceFactorySettings || !`optionVar -exists pathAnimWorldUpTypeOM`) {
  69.         optionVar -stringValue pathAnimWorldUpTypeOM "vector";
  70.     }
  71.  
  72.     if ($forceFactorySettings || !`optionVar -exists pathAnimWorldUpVectorFF`) {
  73.         optionVar -floatValue pathAnimWorldUpVectorFF 0.0
  74.             -floatValueAppend pathAnimWorldUpVectorFF 1.0
  75.             -floatValueAppend pathAnimWorldUpVectorFF 0.0;
  76.     }
  77.  
  78.     if ($forceFactorySettings || !`optionVar -exists pathAnimWorldUpObjectTF`) {
  79.         optionVar -stringValue pathAnimWorldUpObjectTF "";
  80.     }
  81.  
  82.     if ($forceFactorySettings || !`optionVar -exists pathAnimInverseUpCB`) {
  83.         optionVar -intValue pathAnimInverseUpCB 0;
  84.     }
  85.  
  86.     if ($forceFactorySettings || !`optionVar -exists pathAnimInverseFrontCB`) {
  87.         optionVar -intValue pathAnimInverseFrontCB 0;
  88.     }
  89.  
  90.  
  91.  
  92.     //    Bank.
  93.     //
  94.     if ($forceFactorySettings || !`optionVar -exists pathAnimBankCB`) {
  95.         optionVar -intValue pathAnimBankCB 0;
  96.     }
  97.  
  98.     if ($forceFactorySettings || !`optionVar -exists pathAnimBankScaleSG`) {
  99.         optionVar -floatValue pathAnimBankScaleSG 1.0;
  100.     }
  101.  
  102.     if ($forceFactorySettings || !`optionVar -exists pathAnimBankMaxSG`) {
  103.         optionVar -floatValue pathAnimBankMaxSG 90.0;
  104.     }
  105.  
  106.     //    Time.
  107.     //
  108.     if ($forceFactorySettings || !`optionVar -exists pathAnimFrameRangeRB`) {
  109.         optionVar -intValue pathAnimFrameRangeRB 1;
  110.     }
  111.  
  112.     if ($forceFactorySettings || !`optionVar -exists pathAnimStartTimeSG`) {
  113.         optionVar -floatValue pathAnimStartTimeSG 1.0;
  114.     }
  115.  
  116.     if ($forceFactorySettings || !`optionVar -exists pathAnimEndTimeSG`) {
  117.         optionVar -floatValue pathAnimEndTimeSG 30.0;
  118.     }
  119. }
  120.  
  121. //
  122. //  Procedure Name:
  123. //      pathAnimationSetup
  124. //
  125. //  Description:
  126. //        Update the state of the option box UI to reflect the option values.
  127. //
  128. //  Input Arguments:
  129. //      parent               - Top level parent layout of the option box UI.
  130. //                             Required so that UI object names can be 
  131. //                             successfully resolved.
  132. //
  133. //        forceFactorySettings - Whether the option values should be set to
  134. //                             default values.
  135. //
  136. //  Return Value:
  137. //      None.
  138. //
  139. global proc pathAnimationSetup(string $parent, int $forceFactorySettings)
  140. {
  141.     //    Retrieve the option settings
  142.     //
  143.     setOptionVars($forceFactorySettings);
  144.  
  145.     setParent $parent;
  146.  
  147.     //    Query the optionVar's and set the values into the controls.
  148.  
  149.     //    fractionMode.
  150.     //
  151.     checkBoxGrp -edit -v1 `optionVar -query pathAnimParametricLengthCB`
  152.         pathAnimParametricLengthCB;
  153.  
  154.     //    Follow.
  155.     //
  156.     checkBoxGrp -edit -v1 `optionVar -query pathAnimFollowCB`
  157.         pathAnimFollowCB;
  158.  
  159.     radioButtonGrp -edit -select `optionVar -query pathAnimFrontAxisRB`
  160.         pathAnimFrontAxisRB;
  161.  
  162.     radioButtonGrp -edit -select `optionVar -query pathAnimUpAxisRB`
  163.         pathAnimUpAxisRB;
  164.  
  165.     // World up
  166.  
  167.     string $worldUpType = `optionVar -query pathAnimWorldUpTypeOM`;
  168.     switch ( $worldUpType )
  169.     {
  170.     case "scene":
  171.         optionMenuGrp -edit -select 1 pathAnimWorldUpTypeOM;
  172.         break;
  173.     case "object":
  174.         optionMenuGrp -edit -select 2 pathAnimWorldUpTypeOM;
  175.         break;
  176.     case "objectrotation":
  177.         optionMenuGrp -edit -select 3 pathAnimWorldUpTypeOM;
  178.         break;
  179.     case "vector":
  180.         optionMenuGrp -edit -select 4 pathAnimWorldUpTypeOM;
  181.         break;
  182.     case "normal":
  183.         optionMenuGrp -edit -select 5 pathAnimWorldUpTypeOM;
  184.         break;
  185.     }
  186.  
  187.     float $worldUpVector[] = `optionVar -query pathAnimWorldUpVectorFF`;
  188.     floatFieldGrp -edit 
  189.         -value1 $worldUpVector[0]
  190.         -value2 $worldUpVector[1]
  191.         -value3 $worldUpVector[2]
  192.         pathAnimWorldUpVectorFF;
  193.  
  194.     textFieldGrp -edit
  195.         -text `optionVar -query pathAnimWorldUpObjectTF`
  196.         pathAnimWorldUpObjectTF;
  197.  
  198.     checkBoxGrp -edit -v1 `optionVar -query pathAnimInverseUpCB`
  199.         pathAnimInverseUpCB;
  200.  
  201.     checkBoxGrp -edit -v1 `optionVar -query pathAnimInverseFrontCB`
  202.         pathAnimInverseFrontCB;
  203.  
  204.  
  205.  
  206.     //    Bank.
  207.     //
  208.     checkBoxGrp -edit -v1 `optionVar -query pathAnimBankCB`
  209.         pathAnimBankCB;
  210.  
  211.     floatSliderGrp -edit -value `optionVar -query pathAnimBankScaleSG`
  212.         pathAnimBankScaleSG;
  213.  
  214.     floatSliderGrp -edit -value `optionVar -query pathAnimBankMaxSG`
  215.         pathAnimBankMaxSG;
  216.  
  217.     //    Time.
  218.     //
  219.     radioButtonGrp -edit -select `optionVar -query pathAnimFrameRangeRB`
  220.         pathAnimFrameRangeRB;
  221.  
  222.     floatFieldGrp -edit -value1 `optionVar -query pathAnimStartTimeSG`
  223.         pathAnimStartTimeSG;
  224.  
  225.     floatFieldGrp -edit -value1 `optionVar -query pathAnimEndTimeSG`
  226.         pathAnimEndTimeSG;
  227.  
  228.     // When reseting to the factory settings, make sure the visibility
  229.     // or collapse/expand states of the tabs are updated accordingly
  230.     //
  231.     pathAnimEnabling $parent 1;
  232.     pathAnimEnabling $parent 2;
  233.     pathAnimEnabling $parent 3;
  234.     pathAnimEnabling $parent 4;
  235.     pathAnimEnabling $parent 5;
  236.     pathAnimEnabling $parent 6;
  237. }
  238.  
  239. //
  240. //  Procedure Name:
  241. //      pathAnimationCallback
  242. //
  243. //  Description:
  244. //        Update the option values with the current state of the option box UI.
  245. //
  246. //  Input Arguments:
  247. //      parent - Top level parent layout of the option box UI.  Required so
  248. //               that UI object names can be successfully resolved.
  249. //
  250. //        doIt   - Whether the command should execute.
  251. //
  252. //  Return Value:
  253. //      None.
  254. //
  255. global proc pathAnimationCallback(string $parent, int $doIt)
  256. {
  257.     setParent $parent;
  258.  
  259.     //    Set the optionVar's from the control values, and then
  260.     //    perform the command.
  261.  
  262.     //    ParametricLength.
  263.     //
  264.     optionVar -intValue pathAnimParametricLengthCB
  265.         `checkBoxGrp -query -v1 pathAnimParametricLengthCB`;
  266.  
  267.     //    Follow.
  268.     //
  269.     optionVar -intValue pathAnimFollowCB
  270.         `checkBoxGrp -query -v1 pathAnimFollowCB`;
  271.  
  272.     optionVar -intValue pathAnimFrontAxisRB
  273.         `radioButtonGrp -query -select pathAnimFrontAxisRB`;
  274.  
  275.     optionVar -intValue pathAnimUpAxisRB
  276.         `radioButtonGrp -query -select pathAnimUpAxisRB`;
  277.  
  278.     // World up
  279.  
  280.     int $state = `optionMenuGrp -query -select pathAnimWorldUpTypeOM`;
  281.     switch ( $state )
  282.     {
  283.     case 1:
  284.         optionVar -stringValue pathAnimWorldUpTypeOM "scene";
  285.         break;
  286.     case 2:
  287.         optionVar -stringValue pathAnimWorldUpTypeOM "object";
  288.         break;
  289.     case 3:
  290.         optionVar -stringValue pathAnimWorldUpTypeOM "objectrotation";
  291.         break;
  292.     case 4:
  293.         optionVar -stringValue pathAnimWorldUpTypeOM "vector";
  294.         break;
  295.     case 5:
  296.         optionVar -stringValue pathAnimWorldUpTypeOM "normal";
  297.         break;
  298.     }
  299.  
  300.     optionVar -floatValue pathAnimWorldUpVectorFF
  301.         `floatFieldGrp -query -value1 pathAnimWorldUpVectorFF`
  302.         -floatValueAppend pathAnimWorldUpVectorFF
  303.         `floatFieldGrp -query -value2 pathAnimWorldUpVectorFF`
  304.         -floatValueAppend pathAnimWorldUpVectorFF
  305.         `floatFieldGrp -query -value3 pathAnimWorldUpVectorFF`;
  306.  
  307.     optionVar -stringValue pathAnimWorldUpObjectTF
  308.         `textFieldGrp -query -text pathAnimWorldUpObjectTF`;
  309.  
  310.     optionVar -intValue pathAnimInverseUpCB
  311.         `checkBoxGrp -query -v1 pathAnimInverseUpCB`;
  312.  
  313.     optionVar -intValue pathAnimInverseFrontCB
  314.         `checkBoxGrp -query -v1 pathAnimInverseFrontCB`;
  315.  
  316.     //    Bank.
  317.     //
  318.     optionVar -intValue pathAnimBankCB
  319.         `checkBoxGrp -query -v1 pathAnimBankCB`;
  320.  
  321.     optionVar -floatValue pathAnimBankScaleSG
  322.         `floatSliderGrp -query -v pathAnimBankScaleSG`;
  323.  
  324.     optionVar -floatValue pathAnimBankMaxSG
  325.         `floatSliderGrp -query -v pathAnimBankMaxSG`;
  326.  
  327.     //    Time.
  328.     //
  329.     optionVar -intValue pathAnimFrameRangeRB
  330.         `radioButtonGrp -query -select pathAnimFrameRangeRB`;
  331.  
  332.     optionVar -floatValue pathAnimStartTimeSG
  333.         `floatFieldGrp -query -v1 pathAnimStartTimeSG`;
  334.  
  335.     optionVar -floatValue pathAnimEndTimeSG
  336.         `floatFieldGrp -query -v1 pathAnimEndTimeSG`;
  337.  
  338.     if ($doIt) {
  339.         performPathAnimation false; 
  340.         addToRecentCommandQueue "performPathAnimation false" "PathAnimation";
  341.     }
  342. }
  343.  
  344.  
  345. // Callbacks to dim/undim different widgets depending on the states
  346. // of other widgets
  347. //
  348. //    Value of $widget = 1   ....  Update the display of Start/End
  349. //                   = 2   ....  Update the display of Follow options
  350. //                   = 3   ....  Update the display of Bank options
  351. //                   = 4   ....  Make sure Up != Front
  352. //                   = 5   ....  Make sure Front != Up
  353. //                   = 6   ....  Update the display of the world up widgets
  354. //
  355. global proc pathAnimEnabling(string $parent, int $widget)
  356. {
  357.     setParent $parent;
  358.  
  359.     switch($widget)
  360.     {
  361.         case 1: // Update the Start/End display
  362.             int $state = `radioButtonGrp -query -select pathAnimFrameRangeRB`;
  363.             switch ($state)
  364.             {
  365.                 case 1:    // "Time Slider"
  366.                     frameLayout -edit -enable false startFrame;
  367.                     frameLayout -edit -enable false endFrame;
  368.                     break;
  369.                 case 2: // "Start"
  370.                     frameLayout -edit -enable true startFrame;
  371.                     frameLayout -edit -enable false endFrame;
  372.                     break;
  373.                 case 3: // "Start/End"
  374.                     frameLayout -edit -enable true startFrame;
  375.                     frameLayout -edit -enable true endFrame;
  376.                     break;
  377.             }
  378.             break;
  379.  
  380.         case 2:    // Update Follow options display
  381.             int $state = `checkBoxGrp -query -value1 pathAnimFollowCB`;
  382.             frameLayout -edit -enable $state pathAnimationFollowFrame;
  383.             break;
  384.  
  385.         case 3:    // Update Bank options display
  386.             int $followState = `checkBoxGrp -query -value1 pathAnimFollowCB`;
  387.             int $bankState = `checkBoxGrp -query -value1 pathAnimBankCB`;
  388.             if ($followState && $bankState)
  389.                 frameLayout -edit -enable true pathAnimBankFrame;
  390.             else
  391.                 frameLayout -edit -enable false pathAnimBankFrame;
  392.             break;
  393.  
  394.         case 4:    // Make sure the Up is not the same value as the Front
  395.             int      $front = `radioButtonGrp -query -select pathAnimFrontAxisRB`;
  396.             int      $up = `radioButtonGrp -query -select pathAnimUpAxisRB`;
  397.  
  398.             if ($front == $up)
  399.             {
  400.                 int $prevFront = `optionVar -query pathAnimPrevFrontAxis`;
  401.                 radioButtonGrp -edit -select $prevFront pathAnimUpAxisRB;
  402.                 optionVar -intValue pathAnimPrevUpAxis $prevFront;
  403.             }
  404.  
  405.             // Remember the current state of the Front
  406.             //
  407.             optionVar -intValue pathAnimPrevFrontAxis $front;
  408.             break;
  409.  
  410.         case 5:    // Make sure the Front is not the same value as the Up
  411.             int      $front = `radioButtonGrp -query -select pathAnimFrontAxisRB`;
  412.             int      $up = `radioButtonGrp -query -select pathAnimUpAxisRB`;
  413.  
  414.             if ($front == $up)
  415.             {
  416.                 int $prevUp = `optionVar -query pathAnimPrevUpAxis`;
  417.                 radioButtonGrp -edit -select $prevUp pathAnimFrontAxisRB;
  418.                 optionVar -intValue pathAnimPrevFrontAxis $prevUp;
  419.             }
  420.  
  421.             // Remember the current state of the Up
  422.             //
  423.             optionVar -intValue pathAnimPrevUpAxis $up;
  424.             break;
  425.  
  426.         case 6:
  427.             int $followState = `checkBoxGrp -query -value1 pathAnimFollowCB`;
  428.             if ( $followState )
  429.             {
  430.                 int $state = `optionMenuGrp -query -select pathAnimWorldUpTypeOM`;
  431.                 switch ( $state )
  432.                 {
  433.                 case 1: // Scene Up
  434.                 case 5: // Normal
  435.                     floatFieldGrp -edit -enable false pathAnimWorldUpVectorFF;
  436.                     textFieldGrp -edit -enable false pathAnimWorldUpObjectTF;
  437.                     break;
  438.                 case 2: // Object Up
  439.                     floatFieldGrp -edit -enable false pathAnimWorldUpVectorFF;
  440.                     textFieldGrp -edit -enable true pathAnimWorldUpObjectTF;
  441.                     break;
  442.                 case 3: // Object Rotation Up
  443.                     floatFieldGrp -edit -enable true pathAnimWorldUpVectorFF;
  444.                     textFieldGrp -edit -enable true pathAnimWorldUpObjectTF;
  445.                     break;
  446.                 case 4: // Vector
  447.                     floatFieldGrp -edit -enable true pathAnimWorldUpVectorFF;
  448.                     textFieldGrp -edit -enable false pathAnimWorldUpObjectTF;
  449.                     break;
  450.                 }
  451.             }
  452.             else
  453.             {
  454.                 floatFieldGrp -edit -enable false pathAnimWorldUpVectorFF;
  455.                 textFieldGrp -edit -enable false pathAnimWorldUpObjectTF;
  456.             }
  457.             break;
  458.     }
  459. }
  460.  
  461.  
  462. // Create the UI widgets in the option box
  463. //
  464. proc string pathAnimationWidgets(string $parent)
  465. {
  466.     setParent $parent;
  467.  
  468.     string $tabForm = `columnLayout -adjustableColumn true`;
  469.  
  470.        radioButtonGrp -numberOfRadioButtons 3
  471.         -label "Time Range"
  472.         -select 1
  473.         -cc ("pathAnimEnabling " + $parent + " 1")
  474.            -label1 "Time Slider" -columnWidth 2 100
  475.            -label2 "Start"
  476.            -label3 "Start/End"
  477.         pathAnimFrameRangeRB;
  478.  
  479.     frameLayout -bv no -lv no -collapsable yes -collapse no -enable true startFrame;
  480.         columnLayout -adjustableColumn true;
  481.             floatFieldGrp -l "Start Time" pathAnimStartTimeSG;
  482.         setParent ..;
  483.     setParent ..;
  484.  
  485.     frameLayout -bv no -lv no -collapsable yes -collapse no -enable false endFrame;
  486.         columnLayout -adjustableColumn true;
  487.             floatFieldGrp -l "End Time" pathAnimEndTimeSG;
  488.         setParent ..;
  489.     setParent ..;
  490.  
  491.     separator -style "in";
  492.  
  493.     checkBoxGrp -l "Parametric Length" -ncb 1 -l1 " " -v1 false
  494.         pathAnimParametricLengthCB;
  495.  
  496.     checkBoxGrp -l "Follow" -ncb 1 -l1 " " -v1 false
  497.         -cc ("pathAnimEnabling " + $parent + " 2; pathAnimEnabling " + $parent + " 3; pathAnimEnabling " + $parent + " 6")
  498.         pathAnimFollowCB;
  499.  
  500.     frameLayout -bv no -lv no 
  501.         -collapsable true 
  502.         -collapse no 
  503.         -enable false
  504.         pathAnimationFollowFrame;
  505.  
  506.         columnLayout -adjustableColumn true;
  507.             radioButtonGrp -nrb 3 
  508.                 -l "Front Axis"
  509.                 -onc ("pathAnimEnabling " + $parent + " 4")
  510.                 -l1 "X" -l2 "Y" -l3 "Z" 
  511.                 pathAnimFrontAxisRB;
  512.  
  513.             radioButtonGrp -nrb 3 
  514.                 -l "Up Axis"
  515.                 -onc ("pathAnimEnabling " + $parent + " 5")
  516.                 -l1 "X" -l2 "Y" -l3 "Z" 
  517.                 pathAnimUpAxisRB;
  518.  
  519.             optionMenuGrp -l "World Up Type"
  520.                 -cc ("pathAnimEnabling " + $parent + " 6")
  521.                 pathAnimWorldUpTypeOM;
  522.                 menuItem -l "Scene Up"           pathAnimUpDirMI1;
  523.                 menuItem -l "Object Up"          pathAnimUpDirMI2;
  524.                 menuItem -l "Object Rotation Up" pathAnimUpDirMI3;
  525.                 menuItem -l "Vector"             pathAnimUpDirMI4;
  526.                 menuItem -l "Normal"             pathAnimUpDirMI5;
  527.  
  528.             floatFieldGrp -l "World Up Vector" -nf 3 pathAnimWorldUpVectorFF;
  529.  
  530.             textFieldGrp -l "World Up Object" pathAnimWorldUpObjectTF;
  531.  
  532.             checkBoxGrp -ncb 1 -l "" 
  533.                 -l1 "Inverse Up" -v1 false
  534.                 pathAnimInverseUpCB;
  535.  
  536.             checkBoxGrp -ncb 1 -l "" 
  537.                 -l1 "Inverse Front" -v1 false
  538.                 pathAnimInverseFrontCB;
  539.         
  540.             checkBoxGrp -ncb 1 -l "" 
  541.                 -l1 "Bank" 
  542.                 -v1 false
  543.                 -cc ("pathAnimEnabling " + $parent + " 3")
  544.                 pathAnimBankCB;
  545.  
  546.             frameLayout -bv no -lv no 
  547.                 -collapsable true 
  548.                 -enable false 
  549.                 -collapse false
  550.                 pathAnimBankFrame;
  551.  
  552.                 columnLayout -adjustableColumn true;
  553.                     floatSliderGrp -l "Bank Scale"
  554.                         -field true 
  555.                         -min -10.0 -max 10.0 
  556.                         -v 1.0
  557.                         -s 0.1 
  558.                         pathAnimBankScaleSG;
  559.                     floatSliderGrp -l "Bank Limit"
  560.                         -field true 
  561.                         -min -179 -max 179 
  562.                         -v 90
  563.                         -s 1 
  564.                         pathAnimBankMaxSG;
  565.                 setParent ..;
  566.             setParent ..; // pathAnimBankFrame
  567.  
  568.         setParent ..; //
  569.     setParent ..; // pathAnimationFollowFrame
  570.  
  571.     return $tabForm;
  572. }
  573.  
  574.  
  575. //
  576. //  Procedure Name:
  577. //      pathAnimationOptions
  578. //
  579. //  Description:
  580. //        Construct the option box UI.  Involves accessing the standard option
  581. //        box and customizing the UI accordingly.
  582. //
  583. //  Input Arguments:
  584. //      None.
  585. //
  586. //  Return Value:
  587. //      None.
  588. //
  589. proc pathAnimationOptions()
  590. {
  591.     //    Name of the command for this option box.
  592.     //
  593.     string $commandName = "pathAnimation";
  594.  
  595.     //    Build the option box actions.
  596.     //
  597.     string $callback = ($commandName + "Callback");
  598.     string $setup = ($commandName + "Setup");
  599.  
  600.     //    STEP 1:  Get the option box.
  601.     //    ============================
  602.     //
  603.     //  The value returned is the name of the layout to be used as
  604.     //    the parent for the option box UI.
  605.     //
  606.     string $layout = getOptionBox();
  607.     setParent $layout;
  608.     
  609.     //    STEP 2:  Activate the default UI template.
  610.     //    ==========================================
  611.     //
  612.     //    Activate the default UI template so that the layout of this 
  613.     //    option box is consistent with the layout of the rest of the 
  614.     //    application.
  615.     //
  616.     setUITemplate -pushTemplate DefaultTemplate;
  617.  
  618.     //    STEP 3: Create option box contents.
  619.     //    ===================================
  620.     //    
  621.     //    This, of course, will vary from option box to option box.    
  622.     
  623.     //    Turn on the wait cursor.
  624.     //
  625.     waitCursor -state 1;
  626.  
  627.     //    RECOMMENDATION:  Place the UI in a scroll layout.  If the 
  628.     //    option box window is ever resized such that it's entire 
  629.     //    contents is not visible then the scroll bars provided by the
  630.     //    scroll layout will allow the user to access the hidden UI.
  631.     //
  632.     tabLayout -scr true -tv false;
  633.  
  634.     string $parent = `columnLayout -adjustableColumn 1`;
  635.  
  636.  
  637.     // Build the option box contents
  638.     //
  639.     pathAnimationWidgets $parent;
  640.  
  641.  
  642.     //    Turn off the wait cursor.
  643.     //
  644.     waitCursor -state 0;
  645.     
  646.     //    Step 4: Deactivate the default UI template.
  647.     //  ===========================================
  648.     //
  649.     setUITemplate -popTemplate;
  650.  
  651.     //    Step 5: Customize the buttons.  
  652.     //    ==============================
  653.     //
  654.     //    Provide more descriptive labels for the buttons.  This is not 
  655.     //    necessary, but in some cases, for example, a button labelled 
  656.     //    'Create' may be more meaningful to the user than one labelled
  657.     //    'Apply'.
  658.     //
  659.     //  Disable those buttons that are not applicable to the option box.
  660.     //
  661.     //    Attach actions to those buttons that are applicable to the option
  662.     //    box.  Note that the 'Close' button has a default action attached 
  663.     //    to it that will hide the window.  If a custom action is
  664.     //    attached to the 'Close' button then be sure to call the 'hide the
  665.     //    option box' procedure within the custom action so that the option
  666.     //    box is hidden properly.
  667.  
  668.     //    'Apply' button.
  669.     //
  670.     string $applyBtn = getOptionBoxApplyBtn();
  671.     button -edit
  672.         -command ($callback + " " + $parent + " " + 1)
  673.         -label "Attach"
  674.         $applyBtn;
  675.     dimWhen -false "SomethingSelected" $applyBtn;
  676.  
  677.     //    'Save' button.
  678.     //
  679.     string $saveBtn = getOptionBoxSaveBtn();
  680.     button -edit 
  681.         -command ($callback + " " + $parent + " " + 0 + "; hideOptionBox")
  682.         $saveBtn;
  683.  
  684.     //    'Reset' button.
  685.     //
  686.     string $resetBtn = getOptionBoxResetBtn();
  687.     button -edit 
  688.         -command ($setup + " " + $parent + " " + 1)
  689.         $resetBtn;
  690.  
  691.     //    Step 6: Set the option box title.
  692.     //    =================================
  693.     //
  694.     setOptionBoxTitle("Attach to Motion Path Options");
  695.  
  696.     //    Step 7: Customize the 'Help' menu item text.
  697.     //    ============================================
  698.     //
  699.     setOptionBoxHelpTag( "AttachtoMotionPath" );
  700.  
  701.     //    Step 8: Set the current values of the option box.
  702.     //    =================================================
  703.     //
  704.     eval (($setup + " " + $parent + " " + 0));    
  705.     
  706.     //    Step 9: Show the option box.
  707.     //    =================================
  708.     //
  709.     showOptionBox();
  710. }
  711.  
  712.  
  713. //
  714. //  Procedure Name:
  715. //      assembleCmd
  716. //
  717. //  Description:
  718. //        Construct the command that will apply the option box values.
  719. //
  720. //  Input Arguments:
  721. //      None.
  722. //
  723. //  Return Value:
  724. //      None.
  725. //
  726. proc string assembleCmd()
  727. {
  728.     string $cmd = "pathAnimation";
  729.  
  730.     setOptionVars(false);
  731.  
  732.     int        $index = `optionVar -query pathAnimFrontAxisRB`;
  733.     string    $followAxis = "y";
  734.     if( $index == 1 )            $followAxis = "x";
  735.     else if( $index == 3 )        $followAxis = "z";
  736.     
  737.     $index = `optionVar -query pathAnimUpAxisRB`;
  738.     string    $upAxis = "z";
  739.     if( $index == 1 )            $upAxis = "x";
  740.     else if( $index == 2 )        $upAxis = "y";
  741.  
  742.     //    fractionMode option
  743.     //
  744.     if( `optionVar -query pathAnimParametricLengthCB` ) {
  745.         $cmd = ($cmd  + " -fractionMode false" );
  746.     }
  747.     else {
  748.         $cmd = ($cmd  + " -fractionMode true" );
  749.     }
  750.  
  751.     //    follow related options
  752.     //
  753.     if( `optionVar -query pathAnimFollowCB` ) {
  754.         $cmd = ($cmd 
  755.                 + " -follow true"
  756.                 + " -followAxis " + $followAxis
  757.                 + " -upAxis " + $upAxis
  758.                 );
  759.  
  760.         // world up related options
  761.  
  762.         string $worldUpType = `optionVar -query pathAnimWorldUpTypeOM`;
  763.         $cmd = ($cmd  + " -worldUpType " + "\"" + $worldUpType + "\"" );
  764.         switch ( $worldUpType )
  765.         {
  766.         case "scene":
  767.         case "normal":
  768.             break;
  769.         case "object":
  770.             string $worldUpObject = `optionVar -query pathAnimWorldUpObjectTF`;
  771.             $cmd = ($cmd  + " -worldUpObject " + $worldUpObject);
  772.             break;
  773.         case "objectrotation":
  774.             float $worldUpVector[] = `optionVar -query pathAnimWorldUpVectorFF`;
  775.             $cmd = ($cmd  + " -worldUpVector " 
  776.                     + $worldUpVector[0] + " "
  777.                     + $worldUpVector[1] + " "
  778.                     + $worldUpVector[2]);
  779.             string $worldUpObject = `optionVar -query pathAnimWorldUpObjectTF`;
  780.             $cmd = ($cmd  + " -worldUpObject " + $worldUpObject);
  781.             break;
  782.         case "vector":
  783.             float $worldUpVector[] = `optionVar -query pathAnimWorldUpVectorFF`;
  784.             $cmd = ($cmd  + " -worldUpVector " 
  785.                     + $worldUpVector[0] + " "
  786.                     + $worldUpVector[1] + " "
  787.                     + $worldUpVector[2]);
  788.             break;
  789.         }
  790.  
  791.         if( `optionVar -query pathAnimInverseUpCB` ) {
  792.             $cmd = ($cmd  + " -inverseUp true" );
  793.         }
  794.         else {
  795.             $cmd = ($cmd  + " -inverseUp false" );
  796.         }
  797.  
  798.         if( `optionVar -query pathAnimInverseFrontCB` ) {
  799.             $cmd = ($cmd  + " -inverseFront true" );
  800.         }    
  801.         else {
  802.             $cmd = ($cmd  + " -inverseFront false" );
  803.         }
  804.  
  805.  
  806.  
  807.         //    bank related options
  808.         //
  809.         if( `optionVar -query pathAnimBankCB` ) {
  810.             $cmd = ($cmd 
  811.                     + " -bank true"
  812.                     + " -bankScale " + `optionVar -query pathAnimBankScaleSG`
  813.                     + " -bankThreshold " + `optionVar -query pathAnimBankMaxSG`
  814.                 );
  815.         }
  816.         else {
  817.             $cmd = ($cmd + " -bank false" );
  818.         }
  819.     }
  820.     else {
  821.         $cmd = ($cmd + " -follow false" );
  822.     }
  823.  
  824.     //    timing options
  825.     //
  826.     int $timing = `optionVar -query pathAnimFrameRangeRB`;
  827.     if ($timing == 1)    // "Time Slider"
  828.     {
  829.         // Note that we're embedding the time slider query into the string,
  830.         // because if dragged to the shelf with the "Time Slider" option,
  831.         // we want to re-evaluate what the current time slider range is
  832.         // each time it is invoked from the shelf.
  833.         //
  834.         $cmd = ($cmd + " -startTimeU `playbackOptions -query -minTime` "
  835.                  + "-endTimeU  `playbackOptions -query -maxTime`");
  836.     }
  837.     else    // "Start" or "Start/End"
  838.     {
  839.         $cmd = ($cmd+ " -startTimeU " + `optionVar -query pathAnimStartTimeSG`);
  840.  
  841.         if ($timing == 3)    // Start/End
  842.             $cmd = ($cmd+ " -endTimeU " + `optionVar -query pathAnimEndTimeSG`);
  843.     }
  844.  
  845.     return $cmd;
  846. }
  847.  
  848. //
  849. //  Procedure Name:
  850. //      performPathAnimation
  851. //
  852. //  Description:
  853. //        Perform the pathAnimation command using the corresponding 
  854. //        option values.  This procedure will also show the option box
  855. //        window if necessary as well as construct the command string
  856. //        that will invoke the pathAnimation command with the current
  857. //        option box values.
  858. //
  859. //  Input Arguments:
  860. //      0 - Execute the command.
  861. //      1 - Show the option box dialog.
  862. //      2 - Return the command.
  863. //
  864. //  Return Value:
  865. //      None.
  866. //
  867. global proc string performPathAnimation(int $action)
  868. {
  869.     string $cmd = "";
  870.  
  871.     switch ($action) {
  872.  
  873.         //    Execute the command.
  874.         //
  875.         case 0:
  876.             //    Retrieve the option settings
  877.             //
  878.             setOptionVars(false);
  879.  
  880.             //    Get the command.
  881.             //
  882.             $cmd = `assembleCmd`;
  883.  
  884.             //    Execute the command with the option settings.
  885.             //
  886.             evalEcho($cmd);
  887.  
  888.             break;
  889.  
  890.         //    Show the option box.
  891.         //
  892.         case 1:
  893.             pathAnimationOptions;
  894.             break;
  895.  
  896.         //    Return the command string.
  897.         //
  898.         case 2:
  899.             //    Retrieve the option settings.
  900.             //
  901.             setOptionVars (false);
  902.  
  903.             //    Get the command.
  904.             //
  905.             $cmd = `assembleCmd`;
  906.             break;
  907.     }
  908.     return $cmd;
  909. }
  910.  
  911.